@extends('layouts.admin_panel')
@section('style')
    <link rel="stylesheet" type="text/css" href="/assets_admin_panel/global/plugins/select2/select2.css"/>
    <link rel="stylesheet" type="text/css" href="/assets_admin_panel/global/plugins/datatables/extensions/Scroller/css/dataTables.scroller.min.css"/>
    <link rel="stylesheet" type="text/css" href="/assets_admin_panel/global/plugins/datatables/extensions/ColReorder/css/dataTables.colReorder.min.css"/>
    <link rel="stylesheet" type="text/css" href="/assets_admin_panel/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.css"/>
@stop

@section('content')
    <!-- BEGIN PAGE HEADER-->
    <h3 class="page-title"> Liên hệ</h3>
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="{{ URL::to('/admin') }}">Home</a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="{{ URL::to('/admin/category/list') }}">Liên hệ</a>
            </li>
        </ul>
    </div>
    <!-- END PAGE HEADER-->
    
    <!--TABLE-->
    <div class="row">
        <div class="col-sm-12">
            <div class="portlet box red-sunglo">
                <div class="portlet-title">
                    <div class="caption">
                        Danh sách liên hệ
                    </div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;" data-original-title="" title=""> </a>
                        <a class="config" data-toggle="modal" href="#portlet-config" data-original-title="" title=""> </a>
                        <a href="javascript:;" class="reload"></a>
                        <a href="javascript:;" class="remove"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <table class="table table-striped table-bordered table-hover dataTable" id="contact" />
                        <thead>
                            <tr>
                                <th>Email</th>
                                <th>Nội dung</th>
                                <th>Thời gian</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($contacts as $item): ?>
                            <tr>
                                <td>{{ htmlspecialchars($item->email) }}</td>
                                <td>
                                    <?php
                                        $content = htmlspecialchars($contact->content);
                                        $sub_content = substr($content, 0, 200);
                                        if (strlen($content) <= 200)
                                            echo $sub_content;
                                        else {
                                            echo $sub_content.' [...]';
                                        }
                                    ?>
                                </td>
                                <td class='col-center'>{{ $contact->created_at }}</td>
                                <td style="width: 190px !important;">
                                    <a class="btn btn-sm green-meadow has-tooltip" href="{{ URL::to('/admin/contact/view/' . $item->id) }}" style="margin: 0 0 0 7px" title="Xem">
                                        <i class="glyphicon glyphicon-edit "></i>
                                    </a>
                                    <a class="btn btn-sm red has-tooltip" href="#">
                                        <i class="glyphicon glyphicon-trash "></i>
                                    </a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!--END TABLE-->
@stop

@section('scripts')
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/select2/select2.min.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/datatables/media/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.min.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.min.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/datatables/extensions/Scroller/js/dataTables.scroller.min.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/admin/layout/scripts/core.js"></script>
    <script type="text/javascript" src="/assets_admin_panel/admin/layout/scripts/elements/contact.js"></script>
@stop